//
//  HBIncomeDetailHeaderView.m
//  HuoBao
//
//  Created by chaiyanan on 15/12/2.
//  Copyright © 2015年 jinxin. All rights reserved.
//

#import "HBIncomeDetailHeaderView.h"

@interface HBIncomeDetailHeaderView ()

//@property (nonatomic, strong) NSArray *subAry;

@end

@implementation HBIncomeDetailHeaderView

//第二个版本的

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        self.backgroundColor = [LCCommon getColor:@"cfcfcf"];
        [self createCustomView];
        
    }
    return self;
}

- (void)createCustomView
{
    
    self.time = [self createLableWithTextColor:[LCCommon getColor:@"666666"] font:[UIFont systemFontOfSize:12.0f] text:@"2015-11 收益（元）" textAlignment:NSTextAlignmentLeft frame:CGRectMake(15, 0, SCREEN_WIDTH-30, Height_HBIncomeDetailHeaderView) superView:self];
    
}

- (UILabel *)createLableWithTextColor:(UIColor *)color font:(UIFont *)font text:(NSString *)text textAlignment:(NSTextAlignment)textAlignment frame:(CGRect)frame superView:(UIView *)superView
{
    UILabel *lable = [[UILabel alloc]initWithFrame:frame];
    lable.textColor = color;
    lable.font = font;
    lable.text = text;
    lable.textAlignment = textAlignment;
    [superView addSubview:lable];
    return lable;
}

- (UIView *)createSepratorLineWithFrame:(CGRect)frame backgroundColor:(UIColor *)bgColor superView:(UIView *)superView
{
    UIView *sepratorLine = [[UIView alloc]initWithFrame:frame];
    sepratorLine.backgroundColor = bgColor;
    [superView addSubview:sepratorLine];
    return sepratorLine;
}


/*
 //第一个版本的，放开即为第一个版本
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        self.backgroundColor = [LCCommon getColor:@"e1e1e1"];
        self.subAry = @[@"2015-11",@"收益",@"本金收益",@"体验收益",@"加息收益"];
        [self createCustomView];
        
    }
    return self;
}

- (void)createCustomView
{
    float x = 10;
    float width = 50;
    float av = (SCREEN_WIDTH-20-50)/4;
    
    for (int i=0;i<self.subAry.count;i++)
    {
        UIFont *font = [UIFont systemFontOfSize:12.0f];
        if (i==0||i==1)
        {
            font = [UIFont systemFontOfSize:12.0f];
        }
        else
        {
            font = [UIFont systemFontOfSize:11.0f];
        }
        NSTextAlignment textAlignment = NSTextAlignmentCenter;
        if (i==0)
        {
            textAlignment = NSTextAlignmentLeft;
        }
        if (i==self.subAry.count-1)
        {
            textAlignment = NSTextAlignmentRight;
        }
        
        if (i==0)
        {
            
        }
        else if (i==1)
        {
            x=60;
            width = av + 15;
        }
        else
        {
            x+=width;
            width = av - 5;
        }
        CGRect frame = CGRectMake(x, 0, width, 35);
        LLog(@"headerViewFrame:%@",NSStringFromCGRect(frame));
        
       UILabel *lable = [self createLableWithTextColor:[LCCommon getColor:@"666666"] font:font text:self.subAry[i] textAlignment:textAlignment frame:frame superView:self];
        if (i==0)
        {
            self.time = lable;
        }
        else if (i==1)
        {
            self.totalIncome = lable;
        }
        else if (i==2)
        {
            self.bjIncome = lable;
        }
        else if (i==3)
        {
            self.tyIncome = lable;
        }
        else
        {
            self.jxIncome = lable;
        }
    }
    [self createSepratorLineWithFrame:CGRectMake(10, 35-(1/([UIScreen mainScreen].scale)), SCREEN_WIDTH-20, (1/([UIScreen mainScreen].scale))) backgroundColor:[LCCommon getColor:@"cccccc"] superView:self];
    
}

- (UILabel *)createLableWithTextColor:(UIColor *)color font:(UIFont *)font text:(NSString *)text textAlignment:(NSTextAlignment)textAlignment frame:(CGRect)frame superView:(UIView *)superView
{
    UILabel *lable = [[UILabel alloc]initWithFrame:frame];
    lable.textColor = color;
    lable.font = font;
    lable.text = text;
    lable.textAlignment = textAlignment;
    [superView addSubview:lable];
    return lable;
}

- (UIView *)createSepratorLineWithFrame:(CGRect)frame backgroundColor:(UIColor *)bgColor superView:(UIView *)superView
{
    UIView *sepratorLine = [[UIView alloc]initWithFrame:frame];
    sepratorLine.backgroundColor = bgColor;
    [superView addSubview:sepratorLine];
    return sepratorLine;
}
 */

@end
